package com.samphanie.ane.core.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2021/3/12 10:49
 */
@Getter
@Setter
@Validated
@Component
@ConfigurationProperties(prefix = "ane.core")
public class AneCoreProperties {

    @Valid
    private JwtProperties jwt = new JwtProperties();

    private Oauth2Properties oauth2 = new Oauth2Properties();

    private IgnoreUrlsProperties ignoreUrls = new IgnoreUrlsProperties();

    @Getter
    @Setter
    public static class JwtProperties {

        private String header = "Authorization"; // HTTP 报头的认证字段的 key
        private String prefix = "Bearer "; // HTTP 报头的认证字段的值的前缀
        @Min(5000L)
        private long accessTokenExpireTime = 60 * 1000L; // Access Token 过期时间
        @Min(3600000L)
        private long refreshTokenExpireTime = 30 * 24 * 3600 * 1000L; // Refresh Token 过期时间
        private String key;
        private String refreshKey;

    }

    @Getter
    @Setter
    public static class Oauth2Properties {


    }

    @Getter
    @Setter
    public static class IgnoreUrlsProperties {
        // 白名单URL
        private List<String> urls = new ArrayList<>();
    }

}
